﻿using System;
using System.Collections.Generic;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using SilverChart.Configuration;
using SilverChart.Core.Configuration;
using SilverChart.Core.Log;

namespace SilverChart.DotChart {
    public class DotChartConfigurationWrapper {
        private static Logger logger = Logger.GetLogger<DotChartConfigurationWrapper>();

        private Element Data;

        public const String ITEM_NAME_DOTFILL = "fill";
        public readonly static Color DefaultDotFillColor = Colors.Transparent;
        private BrushValueItemHelper dotFill;

        public const String ITEM_NAME_DOTSTROKE = "stroke_color";
        public readonly static Color DefaultDotStroke = Colors.Blue;
        private BrushValueItemHelper dotStroke;

        public const String ITEM_NAME_DOTRADIUS = "radius";
        public const Double DefaultDotRadius = 3.5d;
        private SimpleValueItemHelper<Double> dotRadius;

        public const String ITEM_NAME_DOTSTROKETHICKNESS = "stroke_thickness";
        public const Double DefaultDotStrokeThickness = 2.0d;
        private SimpleValueItemHelper<Double> dotStrokeThichness;

        public DotChartConfigurationWrapper(Element data) {
            Data = data;
            dotFill = new BrushValueItemHelper(Data, ITEM_NAME_DOTFILL, DefaultDotFillColor);
            dotRadius = new SimpleValueItemHelper<Double>(Data, ITEM_NAME_DOTRADIUS, DefaultDotRadius);
            dotStroke = new BrushValueItemHelper(Data, ITEM_NAME_DOTSTROKE, DefaultDotStroke);
            dotStrokeThichness = new SimpleValueItemHelper<Double>(Data, ITEM_NAME_DOTSTROKETHICKNESS, DefaultDotStrokeThickness);
        }

        public Boolean ShowTip { get { return Data.ShowTip; } }
        public IList<Double> Values { get { return Data.Values; } }
        public String LegendName { get { return Data.LegendName; } }

        public Brush DotFill { get { return dotFill.Value; } }
        public Double DotRadius { get { return dotRadius.Value; } }
        public Brush DotStroke { get { return dotStroke.Value; } }
        public Double DotStrokeThickness { get { return dotStrokeThichness.Value; } }

        public readonly static Brush EmptyDotStroke = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
        public readonly static Brush EmptyDotFill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
        public Path Dot {
            get {
                Path dotPath = new Path();
                dotPath.StrokeThickness = DotStrokeThickness;
                dotPath.Cursor = Cursors.Hand;
                dotPath.Stroke = DotStroke;
                dotPath.Fill = DotFill;

                EllipseGeometry ellipse = new EllipseGeometry();
                ellipse.RadiusX = ellipse.RadiusY = DotRadius;
                dotPath.Data = ellipse;
                return dotPath;
            }
        }
    }
}
